home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 276 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.2 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: jbuck@Synopsys.COM (Joe Buck)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: An STL helper -- and template and type shenanigans
  5. Date: 05 Feb 1996 09:22:02 PST
  6. Organization: Synopsys Inc., Mountain View, CA 94043-4033
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4eto87$9kf@hermes.synopsys.com>
  9. References: <01BAEFD6.AD7E8620@dino.int.com> <KANZE.96Feb1141158@slsvewt.lts.sel.alcatel.de>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: 2 Feb 1996 19:21:43 GMT
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBVAwUBMRY8yEy4NqrwXLNJAQF+WwH/a1U0gqcLHONuuZgQj+sAS292xl0/N+QE
  14.     USxnJYyYGz2kCE2bPfKWGwxBPS2BYvSXYP4rs5EYfEvVGrpYrnscag==
  15.     =R9vs
  16. Originator: austern@isolde.mti.sgi.com
  17.  
  18. kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) writes:
  19. >In fact, this is a weakness in the STL definition (IMHO).  STL
  20. >containers require *real* copy constructors, that actually copy.  For
  21. >something like auto_ptr, this is not reasonable.
  22.  
  23. The *language*, not just STL, requires copy constructors that actually
  24. copy.  The language automatically uses the copy constructor whenever it
  25. needs to make a copy.  The copy constructor is used to return objects from
  26. functions and to pass them in by value.  This usaga assumes that you get
  27. an actual copy.  Copy constructors can be optimized away in certain
  28. circumstances.  Again, this optimization works based on the assumption
  29. that a copy constructor does a copy, so you can avoid the copy by
  30. constructing the object in the right place.  It also means that having a
  31. side effect in the copy constructor (other than something that preserves
  32. copy semantics, like reference counting and such) is going to break
  33. things.
  34.  
  35. Any definition of auto_ptr's copy constructor that doesn't follow these
  36. rules is broken, I'm afraid.  The problem is with auto_ptr, not with
  37. copy constructors or the STL.
  38.  
  39. -- 
  40. -- Joe Buck     <jbuck@synopsys.com>    (not speaking for Synopsys, Inc)
  41.  
  42. Work for something because it is good,
  43. not just because it stands a chance to succeed.       -- Vaclav Havel
  44. ---
  45. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  46.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy is
  47.   in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
  48.